/**
 * 用户管理路由
 * 处理后台对普通用户的管理功能
 */

const express = require('express');
const router = express.Router();
const userController = require('../controllers/user.controller');
const { authorize } = require('../middleware/permission.middleware');

/**
 * GET /admin/users
 * 获取用户列表
 * @query {number} page - 页码
 * @query {number} limit - 每页数量
 * @query {string} search - 搜索关键词
 */
router.get('/', authorize(['superadmin', 'admin']), userController.getUserList);

/**
 * GET /admin/users/:id
 * 获取用户详情
 * @param {string} id - 用户ID
 */
router.get('/:id', authorize(['superadmin', 'admin']), userController.getUserDetail);

/**
 * PUT /admin/users/:id
 * 更新用户信息
 * @param {string} id - 用户ID
 * @body {Object} userData - 用户数据
 */
router.put('/:id', authorize(['superadmin', 'admin']), userController.updateUser);

/**
 * PUT /admin/users/:id/status
 * 更新用户状态
 * @param {string} id - 用户ID
 * @body {string} status - 状态值
 */
router.put('/:id/status', authorize(['superadmin', 'admin']), userController.updateUserStatus);

/**
 * GET /admin/users/:id/activities
 * 获取用户活动日志
 * @param {string} id - 用户ID
 */
router.get('/:id/activities', authorize(['superadmin', 'admin']), userController.getUserActivities);

/**
 * GET /admin/users/stats
 * 获取用户统计信息
 */
router.get('/stats/summary', authorize(['superadmin', 'admin']), userController.getUserStats);

module.exports = router;